<template>
     <el-dialog :title="dialogTitle" :visible.sync="editDialogVisible" :append-to-body="true" :before-close="cancel">
        <el-form ref="hashDialogForm" :model="editForm" status-icon :rules="verification">
            <el-form-item label="member" prop="member">
                <el-input v-model="editForm.member"/>
            </el-form-item >
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="saveSet">{{$t('aside.determine')}}</el-button>
            <el-button @click="cancel()">{{$t('aside.cancel')}}</el-button>
        </span>
    </el-dialog>
</template>

<script>
export default {
    props:["editDialogVisible","editFormParam"],
    data(){
        return {
            dialogTitle:"",
            verification:{
                member:[
                    { required: true, message: this.$t("publicFeedback.ValueNotEmpty"), trigger: 'blur' }
                ]
            },
            editForm:{
                member:''
            }
        }
    },
    methods:{
        saveSet(){
            this.$refs.hashDialogForm.validate((valid)=>{
                if(valid){
                    if(this.editFormParam.row){
                        this.$emit("saveSet",this.editFormParam,this.editForm.member)
                    }else{
                        this.$emit("saveSet",null,this.editForm.member)
                    }
                }
            })
        },
        cancel(){
            this.$emit("hideDialog")
        }
    },
    watch:{
        editFormParam(newValue,oldValue){
            if(newValue.row){
                this.dialogTitle=this.$t('publicFeedback.editLine')
                this.editForm.member=newValue.row
            }else{
                this.editForm.member="";
                this.dialogTitle=this.$t('publicFeedback.addLine')
            }
        }
    }
}
</script>

<style>

</style>